/*
Copyright (C) 2003  Pierrick Brihaye
pierrick.brihaye@wanadoo.fr
 
Original Perl code :
Portions (c) 2002 QAMUS LLC (www.qamus.org), 
(c) 2002 Trustees of the University of Pennsylvania 
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the
Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
or connect to:
http://www.fsf.org/copyleft/gpl.html
*/

package gpl.pierrick.brihaye.aramorph;

import gpl.pierrick.brihaye.aramorph.lucene.ArabicNormalizer;

import java.util.Arrays;

/** An abstraction of a dictionary entry for a word. 
 * @author Pierrick Brihaye, 2003
 * @author Ahmed Saad, 2005
 */
public class DictionaryEntry {
	/**unvocalized*/
	private String entry;
	private String normalizedEntry;
	/**vocalized*/
	private String vocalization;
	/**Morphological category*/
	private String morphology;
	/**Glosses*/
	private String[] glosses;
	/**Grammatical categories*/
	private String[] POS;
	/**Lemma*/
	private String lemmaID;
	/**Root of this entry*/
	private String root;
	
	public DictionaryEntry(String entry, String lemmaID, String vocalization, String morphology, String[] glosses, String[] POS, String root) {
		this.root = root;
		this.entry = entry.trim();
		this.normalizedEntry = ArabicNormalizer.normalize(this.entry);
		if (normalizedEntry==null)
			normalizedEntry="";
		this.lemmaID = lemmaID.trim();
		this.vocalization = vocalization.trim();
		this.morphology = morphology.trim();				
		this.glosses = glosses;
		this.POS = POS;
	}
	
	
	public String getEntry(boolean isDictionaryNormalized) {
		return isDictionaryNormalized?this.normalizedEntry:this.entry;
	}
	
	public String getLemmaID() { return this.lemmaID; }
	
	public String getVocalization() { return this.vocalization; }
	
	public String getMorphology() {	return this.morphology; }	
	
	public String[]  getPOS() { return this.POS; }	
			
	public String[] getGlosses() { return this.glosses; }

	public String getRoot() { return this.root; }

	@Override
	public boolean equals(Object obj) {
		DictionaryEntry de = (DictionaryEntry) obj;
		return this.entry.equals(de.entry)
				&& this.morphology.equals(de.morphology)
				&& Arrays.equals(this.glosses, de.glosses)
				&& Arrays.equals(this.POS, de.POS);
	}

	@Override
	public int hashCode() {
		return this.entry.hashCode() + this.lemmaID.hashCode();
	}
}
